fredag 4 april 2014

Multiwii GPS Airplane

                     updated 2014-04-04

This is a addon to the
How to setup a Multiwii Airplane
And Starts from a trimmed MWii Plane

What to expect from a MWii GPS plane?

The code supports.RTH & GPS-Hold.With the simplest FlightController and a Gps. Perfect for exploring the surroundings with your FPV plane.

A good presentation of RTH mode borrowed from Spencer Trejo

Connection Diagram



GPS-Hold

Can be only enabled With AUX switch.
Check Angle mode and Hold in Gui.
When GPS-Hold is activated The position where it was activated  is saved in a 3D Waypoint.
The plane will Navigate and try to "hit" the WP continuously and maintaining altitude.
No pattern is programmed and the plane fly the shortest way back.


RTH (Return to home)

Can be enabled With AUX switch or by Failsafe.
Check Angle mode and RTH in Gui.















When RTH is activated the plane will start Climb to reach safe Altitude.
If RTH is enabled Higher than set altitude it will start navigation and keep that altitude.
If altitude is safe the plane will start to Navigate to home Position.

Only use Angle/Horizon + Gps Home/Hold together.
Do NOT Activate BARO Or MAG for navigation.
It will interfere with the navigation code.

When the plane reaches SAFE_DECSCEND_ZONE the plane will begin descending to correct altitude.
The plane will keep flying in hold mode and continuously pass home.

If Failsafe is active at return The plane will Disarm motor and descending to a "Landing"




PID settings is made in Gui.
ALT & NavR.

Return Altitude can be set with
PosR D-parameter.
Scale is in km...
50m is set as defaut.
250m is Max.




=====================================================
This settings is done  in  Config.h .
=====================================================

#define MAXTHROTTLE 2000 
Because you  want Full Power sometimes!
Mwii uses 1850 for MultiCopters.

Select your GpsType

In My case
#define GPS_PROMINI_SERIAL    115200
#define NMEA
Or 
#define I2C_GPS



Failsafe function

#define FAILSAFE
The obvious reason to have GPS in a plane!
FAILSAFE take over the plane and fly it to Launch point if the Radio is lost.
When Home is reached the plane will stop motor and attempt to make a "Landing"

If Transmitter sends commands below 980µs Mwii will enable Failsafe!
Angle and GPS_HOME become activated.

If you can program failsafe function
on your Receiver Program throttle
To Below 980µs
Or set the switches for RTH.


Safety settings...

#define MOTORSTOP
Give you the chance to Cut motor off with the Throttle Stick.
If Throttle is lowered to zero motor will stop.
Nice when doing preflight checks

Warning...
If you stop motor during Navigation the plane Will most likely Stall!
(Common Aviation Physics...)

=====================================================
This settings is temporarily  in  Gps.h .
=====================================================
The following settings controls the behaviour of the plane during Navigation.
Default settings gives quite soft characteristic.

This values can be set to Zero if Ex Rudder is not used.
#define GPS_MAXCORR    15  // Degrees banking Allowed by GPS.
#define GPS_RUDDER        15  // Maximum Rudder

#define GPS_MAXCLIMB   15     // Max allowed Degrees climbing . To much can stall the plane.
#define GPS_MAXDIVE      15     // Diving . To much can overspeed the plane.


You might need to make some changes to the throttleSettings.
ThrottleSettings in GPS modes

#define CRUICETHROTTLE    1600
The vale  Throttle keeps when Altitude is correct for "Long Distance".
Should be set to a comfortable speed well over Stall Speed.

#define IDLE_THROTTLE      1300
When the plane is descending this is the lowest allowed Throttle.

#define SAFE_NAV_ALT        20  // Meters
To avoid  trees & buildings etc The plane will make a climb straight forward before Navigation starts.

#define SAFE_DECSCEND_ZONE  50 // Meters
 Radius around home where descending is OK

Note!...Don't forget the pre launch check!...

After takeoff do a RTH to ensure Home is set correctly
before Going on a FPV mission

Odd behavior on Rudder

Rudder have a tendency to try to hold the heading during Aileron/Elevator turns.
It can make the plane fly Sideways and other strange phenomena.
The cure is to Set YAW_I = Zero.

=====================================================

A example for a simple setup for RTH

FlightController  $27  Or  NanoWii     $20
Or if you have a DSM2 transmitter AIO FC $28

GPS module     $18

A complete AutoPilot capable to save your plane  under 50$

=====================================================


11 kommentarer:

Thomas Pabst sa...

Hi Patrick.
Can you plz explain which versions from
https://multiwii.googlecode.com/svn/branches/PatrikE/
can be used for planes ?
I am searching for a version that can be used without GPS, too..

THX

Tom

Patrik sa...

Hi Tom,
Latest "Stable" version is the one linked to in the top of this page.
https://multiwii.googlecode.com/svn/branches/PatrikE/FixedWingNav_Dev/FW_Nav_1140402.zip
In this RTH and PosHold works good.

There is also a Ver of EOS_b7.(Needs a Mega2560 Board)
This one have support for waypoint navigation.
It can navigate thru the wp-List.
But the PID's is not perfect and needs some tuning.

Both versions Have working RTH and is safe to use.
All versions works without Gps.
If you enable #FAILSAFE.
The plane will descend in a circle if you loose Signal.

Thomas Pabst sa...

Hi Patrik,
Thank you very much for your quick and detailled answer, i started testing already :)

BR
Tom

Albert Sjoberg sa...

Hello Patrick

Thank you for this, I love what you have done with this project.

I am however struggling to get my aileron servos.
I have the Hobbyking Multiwii pro.
I have identified the outputs for Rudder, Elevator and throttle and flaps. The ailerons do not appear to be on any of the remaining outputs.

The Multiwii config shows the ailerons in and displays the output along with reactions because of movement.

Can you help? Is there a simple way to define the aileron (Roll) output to D9/D10 or D44/D45?

Thank you for your help

Patrik sa...

Hello Albert.
This guide is a complement to the
http://fotoflygarn.blogspot.se/2012/03/how-to-setup-multiwii-airplane-same.html
Where this is explained.

If you use a Mega Board you need to comment
//#define MEGA_HW_PWM_SERVOS
Then you will move Ailerons on
D6 & D7 witch is available on most boards.

Take a look at the first part of the guide for more instuctions on
Setting up the plane for first flights without Gps.
Good luck
/Patrik

Albert Sjoberg sa...

Hello Patrick.

Thank you very much... that solved the problem.
Such a quick reply. Thank you.

Roger Zhong sa...

I am using this version and it works for my Hobby People Super Lightning with GPS, all default PID parameters. I am wondering if the author can add 6 mode aux switch code, similar to arduplane, so I can have one spare channel to control the servo gimbal on a nano-board.

Roger Zhong sa...

The 6 mode aux switch is present in the latest Navi version from Eosbandi, as discussed at http://www.multiwii.com/forum/viewtopic.php?f=7&t=4895

http://eosbandi.com/downloads/

So hopefully the change will be migrated to Patrick's code too

Patrik sa...

Hi Roger,

I have a version based on Eosbandi b7 code.
It's based on the last update before it was merged to MWii branch.
I think the 6 pos switch is included in it (Not sure).

Navigation works but PID's isn't perfect for Missions yet.
I have only flown missions wohin LOS (5 WP circle <150m radius) but it might work better with longer distances.
RTH and PH works fine.
Feel free to test it.
https://code.google.com/p/multiwii/source/browse/#svn%2Fbranches%2FPatrikE%2FFixedWingNav_Dev

Roger Zhong sa...

Hi, Patrik:

Thanks. I actually plug Eosbandi’s 6 mode AUX code into your code over the weekend and then test flight, it works. My code is at
https://www.dropbox.com/s/3t6f6dad6mn99zm/Reference%20140402_airplane_6modeAUX.zip?dl=0

If I had checked your site more frequently, I would not waste this effort. Great to see your new version, and will test it soon.

With this 6 mode AUX code, I can spare AUX2 to control the servo gimbal tilt. Except the gimbal is configured using multwii 2.3 java GUI, others must be configured using the GUI from Eosbandi’s web site.

I had to hard-coded the following change to let AUX2 works for the gimbal tilt.

In Output.cpp
#if defined(SERVO_TILT)
//servo[0] = get_middle(0);
servo[0] = get_middle(0) + rcData[AUX1+1] - 1500;
servo[1] = get_middle(1);

Roger Zhong sa...

As your indicated, EOS_b7 needs a Mega2560 Board. The 6 mode AUX change I made still works on a 328 nano board. Thanks.

原文